﻿using CleanArchitecture.Core.SharedKernel;
using System;
using System.Collections.Generic;

namespace CleanArchitecture.Infrastructure.Entities.SystemModules
{
    /// <summary>
    /// Represents a permission record
    /// </summary>
    public partial class SystemModule : BaseEntity
    {
        private ICollection<AdminRoleSystemModuleMapping> _adminroleSystemModuleMappings;
        private string _displayName;
        /// <summary>
        /// 系统模块名称
        /// </summary>
        public string ModuleName { get; set; }

        public string DisplayName 
        {
            get => string.IsNullOrEmpty(_displayName) ? ModuleName : _displayName;
            set { _displayName = value; }
        }

        /// <summary>
        /// 系统模块类型： 用于区分系统模块为后端显示根目录/顶部菜单/分类菜单/页面
        /// </summary>
        public EntityEnumConfig.SysModuleType ModuleType { get; set; }

        /// <summary>
        /// 系统设计为多级导航菜单模式
        /// </summary>
        public int ParentId { get; set; }
        /// <summary>
        /// 系统模块在页面承现时对应的CSS IconText
        /// </summary>
        public string IconText { get; set; }
        /// <summary>
        /// 系统模块在页面承现时对应的CSS class Name
        /// </summary>
        public string IconCssClass { get; set; }
        /// <summary>
        /// 如果ModuleType为功能页面，则记录该功能页面的MVC UrlRoute
        /// </summary>
        public string UrlRoute { get; set; }
        
        /// <summary>
        /// 该系统模块是否正常使用/或删除
        /// </summary>
        public EntityEnumConfig.YesorNo IsActive { get; set; }
        public int DisplayOrder { get; set; }
        public DateTime CreatedOnTimeUtc { get; set; }

        public EntityEnumConfig.YesorNo OpenOnNewWindow { get; set; }
        /// <summary>
        /// 通过数据字典将系统模块可以操作的按钮ID分配并存储在ModuleButtonIds字段，以逗号分隔多个id
        /// </summary>
        public string ModuleAssignedButtonIds { get; set; }

        public List<int> ModuleAssignedButtons { get; set; }
        
        /// <summary>
        /// Gets or sets the permission record-customer role mappings
        /// </summary>
        public virtual ICollection<AdminRoleSystemModuleMapping> AdminroleSystemModuleMappings
        {
            get => _adminroleSystemModuleMappings ?? (_adminroleSystemModuleMappings = new List<AdminRoleSystemModuleMapping>());
            protected set => _adminroleSystemModuleMappings = value;
        }
    }
}
